/**
 * 
 */
package com.toncen.samepms.fisher.formatter;

import java.util.List;

import com.toncen.samepms.basic.dao.UserDao;
import com.toncen.samepms.basic.domain.User;
import com.toncen.samepms.system.domain.Role;
import com.toncen.samepms.util.SQLUtils;
import com.sky.fisher.formatter.AbstractFormatter;
import com.sky.fisher.model.CommonColumnModel;

/**
 * 描述：角色格式化
 * 
 * @author tch
 * 
 */
public class RoleFormatter extends AbstractFormatter {
	/**
	 * 
	 */
	public RoleFormatter() {

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sky.fisher.formatter.AbstractFormatter#format(com.sky.fisher.model.CommonColumnModel,
	 *      java.lang.String)
	 */
	@Override
	public String format(CommonColumnModel column, String source) throws Exception {
		UserDao<User> userDao = new UserDao<User>();
		User user = userDao.load(Long.parseLong(source));
		List<Role> roles = user.getRoles();
		return SQLUtils.getInSQL(roles,"name");
	}

}
